<template>
  <el-table :data="tableData" border style="width: 100%">
    <el-table-column type="index" label="序号" width="80"> </el-table-column>
    <el-table-column prop="salaryType" label="薪酬类型" width="180">
    </el-table-column>
    <el-table-column prop="ssqq" label="薪酬所属期起"> </el-table-column>
    <el-table-column prop="ssqz" label="薪酬所属期止"> </el-table-column>
    <el-table-column prop="empCount" label="人数"> </el-table-column>
    <el-table-column label="操作">
      <el-button type="primary" size="mini" @click="edit()">编辑</el-button>
      <el-button type="primary" size="mini" @click="delateItem()"
        >删除</el-button
      >
    </el-table-column>
  </el-table>
</template>

<script>
import axios from "axios";
import request from '../utils/request'
import {  getList ,getToken } from "../api/table_main";
export default {
  data() {
    return {
      slipId: "",
      tableData: [
        // {
        //   salaryType: "",
        //   ssqq: "",
        //   ssqz: "",
        //   empCount: "",
        // },
      ],
    };
  },
  created() {
    this.getList();

  },
  methods: {
    //跳转
    edit() {
      this.$router.push("/salaryDetails");
    },
    // 薪酬表显示
    getList() {
      getList().then((res) => {
        getToken()
        console.log(res);
        if (res.data.code == 0) {
          this.tableData = res.data.data;
          this.slipId = res.data.data[0].slipId;
        }
      });
    },

    //删除
    delateItem() {
     request
        .post("/salay/deleteBySlipId", {
          slipId: this.slipId,
        })
        .then((res) => {
          if (res.data.code == 0) {
            this.$message({
              message: "删除成功",
              type: "success",
              duration:2000,
            });
            this.getList();
          }
        })
        .catch((err) => {
          this.$message.error("删除失败");
        });
    },
  },
};
</script>

<style>
.el-table {
  margin-top: 80px;
  text-align: center;
}
</style>
